class Company < ActiveRecord::Base

  set_primary_key 'utilcode'

  has_many :plants, :foreign_key => 'utilcode'
  has_many :generators, :foreign_key => 'utilcode'
  
  OWNER_TYPES = {
    'C' => 'Cooperative',
    'F' => 'Federal',
    'I' => 'Investor Owned',
    'M' => 'Municipal',
    'S' => 'State',
    'O' => 'Other',
    'N' => 'N',
    'Q' => 'Q'
  }

  def ownertype_full
    return OWNER_TYPES[ownertype]
  end
    
  def total_nameplate_capacity
    nameplate = Generator.sum(:nameplate, :conditions => [ "utilcode = ?", self.id ]).to_i  
  end
  
  
end
